package com.situ.stmall.manger.config;
import com.situ.stmall.manger.interceptor.AdminTnterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//配置springMVC
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Value("${upload.path}")
    private String path;

    @Autowired
    AdminTnterceptor adminTnterceptor;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //添加上传图片的映射路径
        //当浏览器访问upload路径下的任何资源时，将从本地资源
        registry.addResourceHandler("/upload/**").addResourceLocations("file:"+path);
    }

    /**
     * 配置拦截器
     * @param registry
     */
/*    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册admin管理员的拦截器,
        registry.addInterceptor(adminTnterceptor)
                .addPathPatterns("/**") //添加要拦截的路径
                .excludePathPatterns(
                        "/layui/**",
                        "/admin/login.html",
                        "/vercode",
                        "/api/admin/login");//排除不需要拦截的路径
    }*/
}
